#include <iostream>

using namespace std;

int lengthOfLongestSubstring(string s) {  
     int count[26];  
     memset(count, -1, 26*sizeof(int));  
     int len=0, maxL = 0;  
     for(int i =0; i< s.size(); i++,len++)  
     {  
          if(count[s[i]-'a']>=0)  
          {  
               maxL = max(len, maxL);  
               len =0;          
               i = count[s[i]-'a']+1;  
               // here it resets because it will start from i again, which if I have a j poiner, it directly goes up. 
               memset(count, -1, 26*sizeof(int));   
          }  
          count[s[i]-'a']=i;  
     }      
     return max(len, maxL);  
} 


int main ()
{
//    string s = "abcbcbc";
    string s = "xyzabcdbefdghijklmn";

    cout << lengthOfLongestSubstring(s) << endl;
}

